
***Purpose: to clean up the student ids by matching baseline and endline student ids
***that don't match
***Last edited: 12th March 2019

// Preliminaries

clear all

cd "[directory]\Raw_data"

use "appended_full clean.dta"

/// RENAMING AND CORRECTING SOME VARS SO THEY ARE CONSISTENT WITH BASELINE VAR NAMES

rename floor_house_303 floor_mat_303
rename roof_house_304 roof_mat_304
rename assets_306_a assets_306_Radio
rename assets_306_b assets_306_Television
rename assets_306_c assets_306_Telephone
rename assets_306_d assets_306_Refrigerator
rename assets_306_e assets_306_Bicycle
rename assets_306_f assets_306_Motorcycle
rename assets_306_g assets_306_PrivateCar
rename assets_306_h assets_306_Other

rename group group_107
rename urban_rural_202 loc_201
rename rent_own_202 house_201
rename board_day_203 board_day_202
rename unit_dist_205 dist_min_203
rename option_500 opt_400e
rename stream_500 stream_400e
rename class_500 class_400e
rename entr_teach_501 entr_teach_401
rename repeats4_503 reptimes4_403
rename repeats5_503 reptimes5_403
rename repeats6_503 reptimes6_403
rename droppeds4_504 droppeds4_404
rename droppeds5_504 droppeds5_404
rename droppeds6_504 droppeds6_404

rename proexam_505 proexam_405
rename aggr_506 aggr_404
rename earn_receive_401 earn_500e	
rename howmuch_401a amt_503
rename savedmon_804 savedmon_804e
rename savedamt_805 savedamt_805e
rename incrproft_903_1 incrproft_1003_SellMorePaper
rename incrproft_903_2 incrproft_1003_IncreasPrice
rename incrproft_903_3 incrproft_1003_EmploySone
rename incrproft_903_4 incrproft_1003_UseCheaperMat
rename growthindic_904 notbusgrth_1004
rename growthindic_904_1 notbusgrth_1004_1
rename growthindic_904_2 notbusgrth_1004_2
rename growthindic_904_3 notbusgrth_1004_3
rename growthindic_904_4 notbusgrth_1004_4
rename growthindic_904_5 notbusgrth_1004_5
rename growthindic_904__66 notbusgrth_1004__66
rename growthindic_904__99 notbusgrth_1004__99

rename knownoproft_905 knownoproft_1005	
rename schooling_1000 schooling_1100
rename occup_1001 occup_1101
rename busnsftr_1002 busnsftr_1102
rename university_1200 univ_1200
rename why_1201 reas_1201
rename why_1203 reas_1203
rename why_1206 reas_1205
rename why_1207 reas_1207
rename why_1209 reas_1209

g str moth_occup_309_other = ""
g str fath_occup_309_other = ""
g str educ_sibling_310_other = ""
g str educ_fath_310_other = ""
g str cook_307_other = ""
g str water_305_other = ""
rename owner_relation_312a bus_info_212relationship_312
g str bus_info_212relationship_312_oth = ""
rename number_paid_312b bus_info_212bus_details_b__312e
rename area_activities_312c bus_info_212bus_details_c__312e
replace first_name_200 = "Zena" if studentid_202 == 431043
replace family_name_200 = "Uwiringiyimana" if studentid_202 == 431043
replace studentid_202 = 4011225 if studentid_202 == 401225
replace reenter_studentid_202 = 4011225 if reenter_studentid_202 == 401225


// WORKING ON STUDENTIDs

//split the student ids so we can generate new uniqueids in line with the baseline - only for specific ids that only had 6 digits

*1st digit of the studentid variable
g studentid2 = substr(string(reenter_studentid_202),1,1) if inlist(reenter_studentid_202,341041,431043,341042,341043,341044,341045,341046,341047,341048,341049,410141,410142,410143,410144,410145,410146,410147,410148,410149,410161,410162,410163,410164,410165,410166,410167,410168,410169,410271,410272,410273,410274,410275,410276,410277,410278,410279,410301,410302,410303,410304,410305,410306,410307,410308,410309,410321,410322,410323,410324,410325,410326,410327,410328,410329,411151,411152,411153,411154,411155,411156,411157,411158,411159,411171,411172,411173,411174,411175,411176,411177,411178,411179,411191,411192,411193,411194,411195,411196,411197,411198,411199,411221,411222,411223,411224,411225,411226,411227,411228,411229,411231,411232,411233,411234,411235,411236,411237,411238,411239,411261,411262,411263,411264,411265,411266,411267,411268,411269,411331,411332,411333,411334,411335,411336,411337,411338,411339,420111,420112,420113,420114,420115,420116,420117,420118,420119,421035,421039,421061,421062,421063,421064,421065,421066,421067,421068,421069,421091,421092,421093,421094,421095,421096,421097,421098,421099,421101,421102,421103,421104,421105,421106,421107,421108,421109,421171,421172,421173,421174,421175,421176,421177,421178,421179,430501,431148,450121,450122,450123,450124,450125,450126,450127,450128,450129,450331,450332,450333,450334,450335,450336,450337,450338,450339,450351,450352,450353,450354)
replace studentid2 = substr(string(reenter_studentid_202),1,1) if inlist(reenter_studentid_202,450355,451177,451316,451176,450356,450357,450358,450359,451001,451002,451003,451004,451005,451006,451007,451008,451009,451022,451023,451024,451026,451027,451041,451042,451044,451045,451046,451047,451048,451049,451051,451052,451053,451054,451055,451056,451057,451058,451059,451061,451062,451063,451064,451065,451066,451067,451068,451069,451111,451112,451113,451114,451115,451116,451117,451118,451119,451121,451122,451123,451124,451125,451126,451127,451128,451129,451131,451132,451133,451134,451135,451136,451137,451138,451139,451141,451142,451143,451144,451145,451146,451147,451148,451149,451151,451152,451154,451155,451156,451157,451158,451159,451171,451172,451173,451174,451175,451178,451179,451191,451192,451193,451194,451195,451196,451197,451198,451199,451201,451202,451203,451204,451205,451206,451207,451208,451209,451231,451232,451233,451234,451235,451236,451237,451238,451239,451241,451242,451243,451244,451245,451246,451247,451248,451249,451261,451262,451263,451264,451265,451266,451267,451268,451269,451301,451302,451303,451304,451305,451306,451307,451308,451309,451331,451332,451333,451334,451335,451336,451337,451338,451339,451361,451362,451363,451364,451365,451366,451367,451368,451369,451391,451392,451393,451394,451395,451396,451397,451398,451399)

*last 5 digits of studentid variable
g studentid3 = substr(string(reenter_studentid_202),2,6) if inlist(reenter_studentid_202,341041,431043,341042,341043,341044,341045,341046,341047,341048,341049,410141,410142,410143,410144,410145,410146,410147,410148,410149,410161,410162,410163,410164,410165,410166,410167,410168,410169,410271,410272,410273,410274,410275,410276,410277,410278,410279,410301,410302,410303,410304,410305,410306,410307,410308,410309,410321,410322,410323,410324,410325,410326,410327,410328,410329,411151,411152,411153,411154,411155,411156,411157,411158,411159,411171,411172,411173,411174,411175,411176,411177,411178,411179,411191,411192,411193,411194,411195,411196,411197,411198,411199,411221,411222,411223,411224,411225,411226,411227,411228,411229,411231,411232,411233,411234,411235,411236,411237,411238,411239,411261,411262,411263,411264,411265,411266,411267,411268,411269,411331,411332,411333,411334,411335,411336,411337,411338,411339,420111,420112,420113,420114,420115,420116,420117,420118,420119,421035,421039,421061,421062,421063,421064,421065,421066,421067,421068,421069,421091,421092,421093,421094,421095,421096,421097,421098,421099,421101,421102,421103,421104,421105,421106,421107,421108,421109,421171,421172,421173,421174,421175,421176,421177,421178,421179,430501,431148,450121,450122,450123,450124,450125,450126,450127,450128,450331,450332,450333,450334,450335,450336,450337,450338,450339,450351,450352,450353,450354)
replace studentid3 = substr(string(reenter_studentid_202),2,6) if inlist(reenter_studentid_202,450355,451177,451316,451176,450356,450357,450358,450359,451001,451002,451003,451004,451005,451006,451007,451008,451009,451022,451023,451024,451026,451027,451041,451042,451044,451045,451046,451047,451048,451049,451051,451052,451053,451054,451055,451056,451057,451058,451059,451061,451062,451063,451064,451065,451066,451067,451068,451069,451111,451112,451113,451114,451115,451116,451117,451118,451119,451121,451122,451123,451124,451125,451126,451127,451128,451129,451131,451132,451133,451134,451135,451136,451137,451138,451139,451141,451142,451143,451144,451145,451146,451147,451148,451149,451151,451152,451154,451155,451156,451157,451158,451159,451171,451172,451173,451174,451175,451178,451179,451191,451192,451193,451194,451195,451196,451197,451198,451199,451201,451202,451203,451204,451205,451206,451207,451208,451209,451231,451232,451233,451234,451235,451236,451237,451238,451239,451241,451242,451243,451244,451245,451246,451247,451248,451249,451261,451262,451263,451264,451265,451266,451267,451268,451269,451301,451302,451303,451304,451305,451306,451307,451308,451309,451331,451332,451333,451334,451335,451336,451337,451338,451339,451361,451362,451363,451364,451365,451366,451367,451368,451369,451391,451392,451393,451394,451395,451396,451397,451398,451399)

** gen a new uniqueid based on studentid and adds a "0" between studentid2 and studentid3 generated above
* this applies to all uniqueids

format studentid_202 %12.0f
tostring studentid_202, generate(uniqueid) format(%12.0f)
replace uniqueid = studentid2 + "0" + studentid3 if inlist(reenter_studentid_202,341041,431043,341042,341043,341044,341045,341046,341047,341048,341049,410141,410142,410143,410144,410145,410146,410147,410148,410149,410161,410162,410163,410164,410165,410166,410167,410168,410169,410271,410272,410273,410274,410275,410276,410277,410278,410279,410301,410302,410303,410304,410305,410306,410307,410308,410309,410321,410322,410323,410324,410325,410326,410327,410328,410329,411151,411152,411153,411154,411155,411156,411157,411158,411159,411171,411172,411173,411174,411175,411176,411177,411178,411179,411191,411192,411193,411194,411195,411196,411197,411198,411199,411221,411222,411223,411224,411225,411226,411227,411228,411229,411231,411232,411233,411234,411235,411236,411237,411238,411239,411261,411262,411263,411264,411265,411266,411267,411268,411269,411331,411332,411333,411334,411335,411336,411337,411338,411339,420111,420112,420113,420114,420115,420116,420117,420118,420119,421035,421039,421061,421062,421063,421064,421065,421066,421067,421068,421069,421091,421092,421093,421094,421095,421096,421097,421098,421099,421101,421102,421103,421104,421105,421106,421107,421108,421109,421171,421172,421173,421174,421175,421176,421177,421178,421179,430501,431148,450121,450122,450123,450124,450125,450126,450127,450128,450331,450332,450333,450334,450335,450336,450337,450338,450339,450351,450352,450353,450354)
replace uniqueid = studentid2 + "0" + studentid3 if inlist(reenter_studentid_202,450355,451177,451316,451176,450356,450357,450358,450359,451001,451002,451003,451004,451005,451006,451007,451008,451009,451022,451023,451024,451026,451027,451041,451042,451044,451045,451046,451047,451048,451049,451051,451052,451053,451054,451055,451056,451057,451058,451059,451061,451062,451063,451064,451065,451066,451067,451068,451069,451111,451112,451113,451114,451115,451116,451117,451118,451119,451121,451122,451123,451124,451125,451126,451127,451128,451129,451131,451132,451133,451134,451135,451136,451137,451138,451139,451141,451142,451143,451144,451145,451146,451147,451148,451149,451151,451152,451154,451155,451156,451157,451158,451159,451171,451172,451173,451174,451175,451178,451179,451191,451192,451193,451194,451195,451196,451197,451198,451199,451201,451202,451203,451204,451205,451206,451207,451208,451209,451231,451232,451233,451234,451235,451236,451237,451238,451239,451241,451242,451243,451244,451245,451246,451247,451248,451249,451261,451262,451263,451264,451265,451266,451267,451268,451269,451301,451302,451303,451304,451305,451306,451307,451308,451309,451331,451332,451333,451334,451335,451336,451337,451338,451339,451361,451362,451363,451364,451365,451366,451367,451368,451369,451391,451392,451393,451394,451395,451396,451397,451398,451399)


replace uniqueid = "40512415" if uniqueid=="4512415"
replace uniqueid = "40503312" if uniqueid=="4503312"
replace uniqueid = "40510413" if uniqueid=="4510413"
replace uniqueid = "350300110" if uniqueid=="35300110"
replace uniqueid = "40512613" if uniqueid=="4512613"
replace uniqueid = "40512311" if uniqueid=="4512311"
replace uniqueid = "40511112" if uniqueid=="4511112"
replace uniqueid = "40510511" if uniqueid=="4510515"
replace uniqueid = "40510012" if uniqueid=="4510012"
replace uniqueid = "04051021" if uniqueid=="451021"
replace uniqueid = "40511712" if uniqueid=="4511712"
replace uniqueid = "40501210" if uniqueid=="4501210"
replace uniqueid = "40503515" if uniqueid=="4503515"
replace uniqueid = "40510516" if uniqueid=="4150516"
replace uniqueid = "40510414" if uniqueid=="4510414"
replace uniqueid = "40503514" if uniqueid=="4503514"
replace uniqueid = "40511711" if uniqueid=="4511711"
replace uniqueid = "40511510" if uniqueid=="4511510"
replace uniqueid = "40503512" if uniqueid=="4503512"
replace uniqueid = "40511515" if uniqueid=="4511515"
replace uniqueid = "40511210" if uniqueid=="4511210"
replace uniqueid = "40503313" if uniqueid=="4503313"
replace uniqueid = "40510011" if uniqueid=="4510011"
replace uniqueid = "40510014" if uniqueid=="4510014"
replace uniqueid = "40510015" if uniqueid=="4510015"
replace uniqueid = "40503315" if uniqueid=="4503315"
replace uniqueid = "70503414" if uniqueid=="50703414"
replace uniqueid = "40510610" if uniqueid=="4510610"
replace uniqueid = "40510612" if uniqueid=="4510612"
replace uniqueid = "40510614" if uniqueid=="4510614"
replace uniqueid = "40510615" if uniqueid=="4510615"
replace uniqueid = "40511111" if uniqueid=="4511111"
replace uniqueid = "40512315" if uniqueid=="4512315"
replace uniqueid = "40512412" if uniqueid=="4512412"
replace uniqueid = "40513015" if uniqueid=="4513015"
replace uniqueid = "40511514" if uniqueid=="4511514"
replace uniqueid = "40511713" if uniqueid=="4511713"
replace uniqueid = "40511110" if uniqueid=="4511110"
replace uniqueid = "40511915" if uniqueid=="4511915"
replace uniqueid = "40511511" if uniqueid=="4511511"
replace uniqueid = "40512013" if uniqueid=="4512013"
replace uniqueid = "04051029" if uniqueid=="451029"
replace uniqueid = "40512015" if uniqueid=="4512015"
replace uniqueid = "40512413" if uniqueid=="4512413"
replace uniqueid = "40513012" if uniqueid=="4513012"
replace uniqueid = "40513314" if uniqueid=="4513314"
replace uniqueid = "40513915" if uniqueid=="4513915"
replace uniqueid = "4051913413" if uniqueid=="451913413"
replace uniqueid = "40501213" if uniqueid=="4501213"
replace uniqueid = "40511914" if uniqueid=="4511914"
replace uniqueid = "40512610" if uniqueid=="4512610"
replace uniqueid = "40512014" if uniqueid=="4512014"
replace uniqueid = "405191348" if uniqueid=="45191348"
replace uniqueid = "04051028" if uniqueid=="451028"
replace uniqueid = "405191342" if uniqueid=="45191342"
replace uniqueid = "040510215" if uniqueid=="4510215"
replace uniqueid = "40513614" if uniqueid=="4513614"
replace uniqueid = "40513910" if uniqueid=="4513910"
replace uniqueid = "40511114" if uniqueid=="4511114"
replace uniqueid = "40511213" if uniqueid=="4511213"
replace uniqueid = "040510211" if uniqueid=="4510211"
replace uniqueid = "40513610" if uniqueid=="4513610"
replace uniqueid = "40503510" if uniqueid=="4503510"
replace uniqueid = "40511412" if uniqueid=="4511412"
replace uniqueid = "40511512" if uniqueid=="4511512"
replace uniqueid = "40511715" if uniqueid=="4511715"
replace uniqueid = "40513912" if uniqueid=="4513912"
replace uniqueid = "40512312" if uniqueid=="4512312"
replace uniqueid = "40510412" if uniqueid=="4510412"
replace uniqueid = "40511414" if uniqueid=="4511414"
replace uniqueid = "40511312" if uniqueid=="4511312"
replace uniqueid = "40513311" if uniqueid=="4513311"
replace uniqueid = "40511311" if uniqueid=="4511311"
replace uniqueid = "40512314" if uniqueid=="4512314"
replace uniqueid = "40510411" if uniqueid=="4510411"
replace uniqueid = "40510415" if uniqueid=="4510415"
replace uniqueid = "40510510" if uniqueid=="4510510"
replace uniqueid = "40513312" if uniqueid=="4513312"
replace uniqueid = "4051913414" if uniqueid=="451913414"
replace uniqueid = "40511411" if uniqueid=="4511411"
replace uniqueid = "40511911" if uniqueid=="4511911"
replace uniqueid = "40511413" if uniqueid=="4511413"
replace uniqueid = "4051913411" if uniqueid=="451913411"
replace uniqueid = "04051025" if uniqueid=="451025"
replace uniqueid = "40513913" if uniqueid=="4513913"
replace uniqueid = "40511410" if uniqueid=="4511410"
replace uniqueid = "40511912" if uniqueid=="4511912"
replace uniqueid = "40512011" if uniqueid=="4512011"
replace uniqueid = "40511310" if uniqueid=="4511310"
replace uniqueid = "40513911" if uniqueid=="4513911"
replace uniqueid = "40512411" if uniqueid=="4512411"
replace uniqueid = "4051913410" if uniqueid=="451913410"
replace uniqueid = "040510212" if uniqueid=="4510212"
replace uniqueid = "4051913415" if uniqueid=="451913415"
replace uniqueid = "40501211" if uniqueid=="4501211"
replace uniqueid = "40503310" if uniqueid=="4503310"
replace uniqueid = "40511313" if uniqueid=="4511313"
replace uniqueid = "405191349" if uniqueid=="45191349"
replace uniqueid = "40511115" if uniqueid=="4511115"
replace uniqueid = "4051913412" if uniqueid=="451913412"
replace uniqueid = "40512012" if uniqueid=="4512012"
replace uniqueid = "40511913" if uniqueid=="4511913"
replace uniqueid = "405191341" if uniqueid=="45191341"
replace uniqueid = "40511714" if uniqueid=="4511714"
replace uniqueid = "40512612" if uniqueid=="4512612"
replace uniqueid = "40511415" if uniqueid=="4511415"
replace uniqueid = "40511910" if uniqueid=="4511910"
replace uniqueid = "40503311" if uniqueid=="4503311"
replace uniqueid = "405191343" if uniqueid=="45191343"
replace uniqueid = "40512414" if uniqueid=="4512414"
replace uniqueid = "40510010" if uniqueid=="4510010"
replace uniqueid = "40513313" if uniqueid=="4513313"
replace uniqueid = "40513010" if uniqueid=="4513010"
replace uniqueid = "40512611" if uniqueid=="4512611"
replace uniqueid = "40513914" if uniqueid=="4513914"
replace uniqueid = "40503511" if uniqueid=="4503511"
replace uniqueid = "4011225" if uniqueid=="401225"
replace uniqueid = "40511211" if uniqueid=="4511211"
replace uniqueid = "040510210" if  studentid_202 == 4510210
replace uniqueid = "040510213" if  studentid_202 == 40510213
replace uniqueid = "040510214" if  studentid_202 == 4510214
replace uniqueid = "04051022" if  studentid_202 == 4051022
replace uniqueid = "04051023" if  studentid_202 == 451023
replace uniqueid = "04051024" if  studentid_202 == 4051024
replace uniqueid = "04051026" if  studentid_202 == 4051026
replace uniqueid = "04051027" if  studentid_202 == 451027
replace uniqueid = "3011171" if  studentid_202 == 3021171
replace uniqueid = "30111710" if  studentid_202 == 30211710
replace uniqueid = "30111711" if  studentid_202 == 30211711
replace uniqueid = "30111712" if  studentid_202 == 30211712
replace uniqueid = "30111714" if  studentid_202 == 30211714
replace uniqueid = "30111715" if  studentid_202 == 30211715
replace uniqueid = "30111713" if  studentid_202 == 3021173
replace uniqueid = "3011174" if  studentid_202 == 3021174
replace uniqueid = "3011175" if  studentid_202 == 3021175
replace uniqueid = "3011176" if  studentid_202 == 3021176
replace uniqueid = "3011177" if  studentid_202 == 3021177
replace uniqueid = "3011178" if  studentid_202 == 3021178
replace uniqueid = "3011179" if  studentid_202 == 3021179
replace uniqueid = "3011171" if  studentid_202 == 3021171
replace uniqueid = "30111710" if  studentid_202 == 30211710
replace uniqueid = "30111711" if  studentid_202 == 30211711
replace uniqueid = "30111712" if  studentid_202 == 30211712
replace uniqueid = "30111713" if  studentid_202 == 3021173
replace uniqueid = "30111714" if  studentid_202 == 30211714
replace uniqueid = "30111715" if  studentid_202 == 30211715
replace uniqueid = "40510212" if  studentid_202 == 504102112
replace uniqueid = "40510215" if  studentid_202 == 504102115
replace uniqueid = "5071083" if  studentid_202 == 5071081
replace uniqueid = "5071126" if  studentid_202 == 4051025

save "appended_full clean_updated.dta", replace

/*
drop studentid2 studentid3
g unq = substr(uniqueid,1,6) 
//destring unq, replace force //only run this line if you want to compare unq with schoolid and correct for errors
*/

*** merging in section 3 from the baseline into the endline

*extract section3 from the baseline clean data

clear all
use "[directory]/Student_Survey_cleaned.dta"

keep uniqueid age_300 gender_301 water_305_other cook_307_other parents_302 educ_fath_310_other educ_sibling_310_other fath_occup_309 fath_occup_309_other moth_occup_309_other moth_occup_309 cook_307 light_308 floor_mat_303 assets_306_Other assets_306_PrivateCar assets_306_Motorcycle roof_mat_304 water_305 assets_306_Radio assets_306_Television assets_306_Telephone assets_306_Refrigerator assets_306_Bicycle educ_fath_310 educ_moth_310 educ_sibling_310 business_311 bus_info_212relationship_312  

save "[directory]\baseline_section3.dta", replace

*extract section 3 from the endline appended_full clean_updated data set

use "appended_full clean_updated.dta", clear
keep uniqueid baseline_student
keep if baseline_student==1

save "[directory]\endline_section3.dta", replace //check that the generated dataset has all missing values except for 'baseline_student' and 'uniqueid'


merge 1:1 uniqueid using "[directory]/baseline_section3.dta"

drop if _merge!=3 // only keep the ones that match
drop _merge

* rename section 3 in the new data set for ease of merging with the larger endline data set
foreach var in age_300 gender_301 water_305_other cook_307_other parents_302 educ_fath_310_other educ_sibling_310_other fath_occup_309 fath_occup_309_other moth_occup_309_other moth_occup_309 cook_307 light_308 floor_mat_303 assets_306_Other assets_306_PrivateCar assets_306_Motorcycle roof_mat_304 water_305 assets_306_Radio assets_306_Television assets_306_Telephone assets_306_Refrigerator assets_306_Bicycle educ_fath_310 educ_moth_310 educ_sibling_310 business_311 bus_info_212relationship_312 {

  rename `var' `var'test
  
  }

save "[directory]/merged_section3.dta", replace

use "appended_full clean_updated.dta", clear

drop _merge


merge 1:1 uniqueid using "[directory]/merged_section3.dta"

foreach var in age_300 gender_301 water_305_other cook_307_other parents_302 educ_fath_310_other educ_sibling_310_other fath_occup_309 fath_occup_309_other moth_occup_309_other moth_occup_309 cook_307 light_308 floor_mat_303 assets_306_Other assets_306_PrivateCar assets_306_Motorcycle roof_mat_304 water_305 assets_306_Radio assets_306_Television assets_306_Telephone assets_306_Refrigerator assets_306_Bicycle educ_fath_310 educ_moth_310 educ_sibling_310 business_311 bus_info_212relationship_312 {

  replace `var' = `var'test if _merge == 3
  drop `var'test
  }

drop studentid2 studentid3

save "appended_full clean_updated.dta",replace

keep if _merge!=3 & baseline_student==1

save "[directory]\these_ids_miss_section3.dta",replace

use "appended_full clean_updated.dta", clear
drop _merge

save "appended_full clean_updated.dta",replace

*******************CORRECTING SCHOOL IDs*****************************************


use "[directory]\group_107_corrected.dta", clear //this data set has all correct school ids (pre-load to surveycto)

merge 1:m schoolid using "appended_full clean_updated.dta"

replace correct_group = "1" if correct_group == "Group 1 Treatment"
replace correct_group = "2" if correct_group == "Group 2 Control"
destring correct_group, replace
la var correct_group "Group"
la de correct_group 1 "Treatment" 2 "Control"
la val correct_group correct_group
drop if _merge == 1


//MAKING CORRECTIONS BASED ON CHECKS AFTER MERGING

**checking if the two group matches//FOR CHECKING PURPOSES ONLY
gen group_check = 1 if correct_group != group_107
order group_check, after(group_107)
order school_name, after(group_check)

**Correcting IDs
replace correct_group = 2 if studentid_202 == 30410611 & key == "uuid:7c780de3-f56e-41ee-8225-1a8a42aca5b7"
replace group_107 = 2 if studentid_202 == 30410611 & key == "uuid:7c780de3-f56e-41ee-8225-1a8a42aca5b7"
replace schoolid = 403112 if studentid_202 == 30410611 & key == "uuid:7c780de3-f56e-41ee-8225-1a8a42aca5b7"
replace reenter_schoolid = 403112 if studentid_202 == 30410611 & key == "uuid:7c780de3-f56e-41ee-8225-1a8a42aca5b7"

replace correct_group = 2 if studentid_202 == 30512611 & key == "uuid:8d9f3413-2ca9-4b57-bc18-0ec4d2d6a932"
replace group_107 = 2 if studentid_202 == 30512611 & key == "uuid:8d9f3413-2ca9-4b57-bc18-0ec4d2d6a932"
replace schoolid = 507108 if studentid_202 == 30512611 & key == "uuid:8d9f3413-2ca9-4b57-bc18-0ec4d2d6a932"
replace reenter_schoolid = 507108 if studentid_202 == 30512611 & key == "uuid:8d9f3413-2ca9-4b57-bc18-0ec4d2d6a932"

replace correct_group = 1 if studentid_202 == 5071201 & key == "uuid:f20f0cfa-ff81-4463-a466-d7dd3765ab0e"
replace group_107 = 1 if studentid_202 == 5071201 & key == "uuid:f20f0cfa-ff81-4463-a466-d7dd3765ab0e"
replace schoolid = 507121 if studentid_202 == 5071201 & key == "uuid:f20f0cfa-ff81-4463-a466-d7dd3765ab0e"
replace reenter_schoolid = 507121 if studentid_202 == 5071201 & key == "uuid:f20f0cfa-ff81-4463-a466-d7dd3765ab0e"

replace correct_group = 2 if studentid_202 == 5040199 & key == "uuid:9c2c5cd7-eb6e-4e53-8f46-c7165681c3c4"
replace group_107 = 2 if studentid_202 == 5040199 & key == "uuid:9c2c5cd7-eb6e-4e53-8f46-c7165681c3c4"
replace schoolid = 504124 if studentid_202 == 5040199 & key == "uuid:9c2c5cd7-eb6e-4e53-8f46-c7165681c3c4"
replace reenter_schoolid = 504124 if studentid_202 == 5040199 & key == "uuid:9c2c5cd7-eb6e-4e53-8f46-c7165681c3c4"

replace correct_group = 2 if studentid_202 == 3041163 & key == "uuid:260b2989-8e08-4853-8dfe-bb556e1435b1"
replace group_107 = 2 if studentid_202 == 3041163 & key == "uuid:260b2989-8e08-4853-8dfe-bb556e1435b1"
replace schoolid = 503117 if studentid_202 == 3041163 & key == "uuid:260b2989-8e08-4853-8dfe-bb556e1435b1"
replace reenter_schoolid = 503117 if studentid_202 == 3041163 & key == "uuid:260b2989-8e08-4853-8dfe-bb556e1435b1"

replace correct_group = 2 if studentid_202 == 50712110 & key == "uuid:472ebe7f-434b-474e-b670-15c446740e28"
replace group_107 = 2 if studentid_202 == 50712110 & key == "uuid:472ebe7f-434b-474e-b670-15c446740e28"
replace schoolid = 507101 if studentid_202 == 50712110  & key == "uuid:472ebe7f-434b-474e-b670-15c446740e28"
replace reenter_schoolid = 507101 if studentid_202 == 50712110 & key == "uuid:472ebe7f-434b-474e-b670-15c446740e28"

replace correct_group = 2 if studentid_202 == 5030524 & key == "uuid:d7dd53f5-2008-420d-b7f9-271a4baf2fd1"
replace group_107 = 2 if studentid_202 == 5030524 & key == "uuid:d7dd53f5-2008-420d-b7f9-271a4baf2fd1"
replace schoolid = 503052 if studentid_202 == 5030524 & key == "uuid:d7dd53f5-2008-420d-b7f9-271a4baf2fd1"
replace reenter_schoolid = 503052 if studentid_202 == 5030524 & key == "uuid:d7dd53f5-2008-420d-b7f9-271a4baf2fd1"

replace correct_group = 1  if studentid_202 == 5040118 & key == "uuid:f72d40b5-1253-472f-82da-e363af01da27"
replace group_107 = 1 if studentid_202 == 5040118 & key == "uuid:f72d40b5-1253-472f-82da-e363af01da27"
replace schoolid = 504020 if studentid_202 == 5040118 & key == "uuid:f72d40b5-1253-472f-82da-e363af01da27"
replace reenter_schoolid = 504020 if studentid_202 == 5040118 & key == "uuid:f72d40b5-1253-472f-82da-e363af01da27"


replace correct_group = 2 if studentid_202 == 50305513 & key == "uuid:344fa47a-a1f6-4791-a3f3-ad6d14f04563"
replace group_107 = 2 if studentid_202 == 50305513 & key == "uuid:344fa47a-a1f6-4791-a3f3-ad6d14f04563"
replace schoolid = 504054 if studentid_202 == 50305513 & key == "uuid:344fa47a-a1f6-4791-a3f3-ad6d14f04563"
replace reenter_schoolid = 504054 if studentid_202 == 50305513 & key == "uuid:344fa47a-a1f6-4791-a3f3-ad6d14f04563"

replace correct_group = 2 if studentid_202 == 5041116 & key == "uuid:1587ece0-cfa5-464c-89dd-af29a920d222"
replace group_107 = 2 if studentid_202 == 5041116 & key == "uuid:1587ece0-cfa5-464c-89dd-af29a920d222"
replace schoolid = 504054 if studentid_202 == 5041116 & key == "uuid:1587ece0-cfa5-464c-89dd-af29a920d222"
replace reenter_schoolid = 504054 if studentid_202 == 5041116 & key == "uuid:1587ece0-cfa5-464c-89dd-af29a920d222"

replace correct_group = 2 if studentid_202 == 5040306 & key == "uuid:fa3f3294-8fa4-4c98-a6cc-530c7d72cd70"
replace group_107 = 2 if studentid_202 == 5040306 & key == "uuid:fa3f3294-8fa4-4c98-a6cc-530c7d72cd70"
replace schoolid = 504015 if studentid_202 == 5040306 & key == "uuid:fa3f3294-8fa4-4c98-a6cc-530c7d72cd70"
replace reenter_schoolid = 504015 if studentid_202 == 5040306 & key == "uuid:fa3f3294-8fa4-4c98-a6cc-530c7d72cd70"

replace correct_group = 2 if studentid_202 == 5040188 & key == "uuid:4afca5c4-8a3f-4ed0-97bd-b6810ea24dbc"
replace group_107 = 2 if studentid_202 == 5040188 & key == "uuid:4afca5c4-8a3f-4ed0-97bd-b6810ea24dbc"
replace schoolid = 504112 if studentid_202 == 5040188 & key == "uuid:4afca5c4-8a3f-4ed0-97bd-b6810ea24dbc"
replace reenter_schoolid = 504112 if studentid_202 == 5040188 & key == "uuid:4afca5c4-8a3f-4ed0-97bd-b6810ea24dbc"

replace correct_group = 1 if studentid_202 == 5040308 & key == "uuid:20ed43be-c8c9-46c9-b472-43a9b5559120"
replace group_107 = 1 if studentid_202 == 5040308 & key == "uuid:20ed43be-c8c9-46c9-b472-43a9b5559120"
replace schoolid = 504109 if studentid_202 == 5040308 & key == "uuid:20ed43be-c8c9-46c9-b472-43a9b5559120"
replace reenter_schoolid = 504109 if studentid_202 == 5040308 & key == "uuid:20ed43be-c8c9-46c9-b472-43a9b5559120"

replace correct_group = 1 if studentid_202 == 50405614 & key == "uuid:a6f79df1-73c1-40a0-8746-44cd6cb19590"
replace group_107 = 1 if studentid_202 == 50405614 & key == "uuid:a6f79df1-73c1-40a0-8746-44cd6cb19590"
replace schoolid = 504109 if studentid_202 == 50405614 & key == "uuid:a6f79df1-73c1-40a0-8746-44cd6cb19590"
replace reenter_schoolid = 504109 if studentid_202 == 50405614 & key == "uuid:a6f79df1-73c1-40a0-8746-44cd6cb19590"

replace correct_group = 1 if studentid_202 == 5030319 & key == "uuid:ae9c6da8-e1a2-401a-97ac-17a7fa85caaf"
replace group_107 = 1 if studentid_202 == 5030319 & key == "uuid:ae9c6da8-e1a2-401a-97ac-17a7fa85caaf"
replace schoolid = 504109 if studentid_202 == 5030319 & key == "uuid:ae9c6da8-e1a2-401a-97ac-17a7fa85caaf"
replace reenter_schoolid = 504109 if studentid_202 == 5030319 & key == "uuid:ae9c6da8-e1a2-401a-97ac-17a7fa85caaf"

replace correct_group = 1 if studentid_202 == 5041117 & key == "uuid:97951548-3d45-432f-8ef0-f65c70323f88"
replace group_107 = 1 if studentid_202 == 5041117 & key == "uuid:97951548-3d45-432f-8ef0-f65c70323f88"
replace schoolid = 504056 if studentid_202 == 5041117 & key == "uuid:97951548-3d45-432f-8ef0-f65c70323f88"
replace reenter_schoolid = 504056 if studentid_202 == 5041117 & key == "uuid:97951548-3d45-432f-8ef0-f65c70323f88"

replace school_name = 158 if schoolid == 301117
replace school_name = 66 if schoolid == 507101

replace correct_group = 2 if studentid_202 == 50611410 & key == "uuid:14cfd26f-f401-4452-8473-b3505d89325d"
replace group_107 = 2 if studentid_202 == 50611410 & key == "uuid:14cfd26f-f401-4452-8473-b3505d89325d"
replace schoolid = 506102 if studentid_202 == 50611410 & key == "uuid:14cfd26f-f401-4452-8473-b3505d89325d"
replace reenter_schoolid = 506102 if studentid_202 == 50611410 & key == "uuid:14cfd26f-f401-4452-8473-b3505d89325d"


replace correct_group = 1 if studentid_202 == 50305012 & key == "uuid:21888b8b-ea99-49a2-8d6c-65d224ec31df"
replace group_107 = 1 if studentid_202 == 50305012 & key == "uuid:21888b8b-ea99-49a2-8d6c-65d224ec31df"
replace schoolid = 506101 if studentid_202 == 50305012 & key == "uuid:21888b8b-ea99-49a2-8d6c-65d224ec31df"
replace reenter_schoolid = 506101 if studentid_202 == 50305012 & key == "uuid:21888b8b-ea99-49a2-8d6c-65d224ec31df"


replace correct_group = 1 if studentid_202 == 4051246 & key == "uuid:686361fa-8f3f-4a68-bc8d-6ade48ff52d0"
replace group_107 = 1 if studentid_202 == 4051246 & key == "uuid:686361fa-8f3f-4a68-bc8d-6ade48ff52d0"
replace schoolid = 506032 if studentid_202 == 4051246 & key == "uuid:686361fa-8f3f-4a68-bc8d-6ade48ff52d0"
replace reenter_schoolid = 506032 if studentid_202 == 4051246 & key == "uuid:686361fa-8f3f-4a68-bc8d-6ade48ff52d0"

replace correct_group = 2 if studentid_202 == 50611514 & key == "uuid:7908723d-48a6-463e-abda-90712dead574"
replace group_107 = 2 if studentid_202 == 50611514 & key == "uuid:7908723d-48a6-463e-abda-90712dead574"
replace schoolid = 506114 if studentid_202 == 50611514 & key == "uuid:7908723d-48a6-463e-abda-90712dead574"
replace reenter_schoolid = 506114 if studentid_202 == 50611514 & key == "uuid:7908723d-48a6-463e-abda-90712dead574"


replace correct_group = 1 if studentid_202 == 50305011 & key == "uuid:81b60915-3ab1-43e1-b23f-663554e0ae3a"
replace group_107 = 1 if studentid_202 == 50305011 & key == "uuid:81b60915-3ab1-43e1-b23f-663554e0ae3a"
replace schoolid = 506016 if studentid_202 == 50305011 & key == "uuid:81b60915-3ab1-43e1-b23f-663554e0ae3a"
replace reenter_schoolid = 506016 if studentid_202 == 50305011 & key == "uuid:81b60915-3ab1-43e1-b23f-663554e0ae3a"

replace correct_group = 1 if studentid_202 == 5030502 & key == "uuid:6a22c37d-2e96-46c7-b330-2b37b0512f4f"
replace group_107 = 1 if studentid_202 == 5030502 & key == "uuid:6a22c37d-2e96-46c7-b330-2b37b0512f4f"
replace schoolid = 506016 if studentid_202 == 5030502 & key == "uuid:6a22c37d-2e96-46c7-b330-2b37b0512f4f"
replace reenter_schoolid = 506016 if studentid_202 == 5030502 & key == "uuid:6a22c37d-2e96-46c7-b330-2b37b0512f4f"

replace correct_group = 1 if studentid_202 == 50305015 & key == "uuid:34fa36a5-9b33-4bb1-8237-7f6951a255e4"
replace group_107 = 1 if studentid_202 == 50305015 & key == "uuid:34fa36a5-9b33-4bb1-8237-7f6951a255e4"
replace schoolid = 506016 if studentid_202 == 50305015 & key == "uuid:34fa36a5-9b33-4bb1-8237-7f6951a255e4"
replace reenter_schoolid = 506016 if studentid_202 == 50305015 & key == "uuid:34fa36a5-9b33-4bb1-8237-7f6951a255e4"

replace correct_group = 1 if studentid_202 == 5041179 & key == "uuid:72847529-6bea-4783-8d99-42be858bf60f"
replace group_107 = 1 if studentid_202 == 5041179 & key == "uuid:72847529-6bea-4783-8d99-42be858bf60f"
replace schoolid = 506105 if studentid_202 == 5041179 & key == "uuid:72847529-6bea-4783-8d99-42be858bf60f"
replace reenter_schoolid = 506105 if studentid_202 == 5041179 & key == "uuid:72847529-6bea-4783-8d99-42be858bf60f"


replace correct_group = 2 if studentid_202 == 5061002 & key == "uuid:d346c166-f61a-43eb-bcd2-152c39e78465"
replace group_107 = 2 if studentid_202 == 5061002 & key == "uuid:d346c166-f61a-43eb-bcd2-152c39e78465"
replace schoolid = 506117 if studentid_202 == 5061002 & key == "uuid:d346c166-f61a-43eb-bcd2-152c39e78465"
replace reenter_schoolid = 506117 if studentid_202 == 5061002 & key == "uuid:d346c166-f61a-43eb-bcd2-152c39e78465"


replace correct_group = 2 if studentid_202 == 5030501 & key == "uuid:9d032e35-4296-4b86-8674-746890881834"
replace group_107 = 2 if studentid_202 == 5030501 & key == "uuid:9d032e35-4296-4b86-8674-746890881834"
replace schoolid = 506033 if studentid_202 == 5030501 & key == "uuid:9d032e35-4296-4b86-8674-746890881834"
replace reenter_schoolid = 506033 if studentid_202 == 5030501 & key == "uuid:9d032e35-4296-4b86-8674-746890881834"


replace correct_group =1  if studentid_202 == 3050103 & key == "uuid:74730f3e-f8e1-4304-b764-997e7e368e8b"
replace group_107 = 1 if studentid_202 == 3050103 & key == "uuid:74730f3e-f8e1-4304-b764-997e7e368e8b"
replace schoolid = 402117 if studentid_202 == 3050103 & key == "uuid:74730f3e-f8e1-4304-b764-997e7e368e8b"
replace reenter_schoolid = 402117 if studentid_202 == 3050103 & key == "uuid:74730f3e-f8e1-4304-b764-997e7e368e8b"

replace correct_group = 1 if studentid_202 == 4051261 & key == "uuid:33e26f84-9e21-4be5-8421-c03b10a13660"
replace group_107 = 1 if studentid_202 == 4051261 & key == "uuid:33e26f84-9e21-4be5-8421-c03b10a13660"
replace schoolid = 405102 if studentid_202 == 4051261 & key == "uuid:33e26f84-9e21-4be5-8421-c03b10a13660"
replace reenter_schoolid = 405102 if studentid_202 == 4051261 & key == "uuid:33e26f84-9e21-4be5-8421-c03b10a13660"

replace correct_group = 1 if studentid_202 == 5071089 & key == "uuid:8480388c-a2c8-40fb-b2d7-90cd44dbd40b"
replace group_107 = 1 if studentid_202 == 5071089 & key == "uuid:8480388c-a2c8-40fb-b2d7-90cd44dbd40b"
replace schoolid = 405104 if studentid_202 == 5071089 & key == "uuid:8480388c-a2c8-40fb-b2d7-90cd44dbd40b"
replace reenter_schoolid = 405104 if studentid_202 == 5071089 & key == "uuid:8480388c-a2c8-40fb-b2d7-90cd44dbd40b"


replace correct_group = 1 if studentid_202 == 5030329 & key == "uuid:4ef21162-3e7b-48db-987b-768bfc730560"
replace group_107 = 1 if studentid_202 == 5030329 & key == "uuid:4ef21162-3e7b-48db-987b-768bfc730560"
replace schoolid = 405033 if studentid_202 == 5030329 & key == "uuid:4ef21162-3e7b-48db-987b-768bfc730560"
replace reenter_schoolid = 405033 if studentid_202 == 5030329 & key == "uuid:4ef21162-3e7b-48db-987b-768bfc730560"

replace correct_group = 2 if studentid_202 == 4051365 & key == "uuid:16b9d84d-4b98-4fa5-9d86-dfe92259d446"
replace group_107 = 2 if studentid_202 == 4051365 & key == "uuid:16b9d84d-4b98-4fa5-9d86-dfe92259d446"
replace schoolid = 405106 if studentid_202 == 4051365 & key == "uuid:16b9d84d-4b98-4fa5-9d86-dfe92259d446"
replace reenter_schoolid = 405106 if studentid_202 == 4051365 & key == "uuid:16b9d84d-4b98-4fa5-9d86-dfe92259d446"

replace school_name = 101 if studentid_202 == 4051136 & key == "uuid:95c1a328-bd01-4746-b7fb-4e6d44656dea"

replace correct_group = 1 if studentid_202 == 40111215 & key == "uuid:209416ff-7516-4d59-b326-24039833a968"
replace group_107 = 1 if studentid_202 == 40111215 & key == "uuid:209416ff-7516-4d59-b326-24039833a968"
replace schoolid = 405115 if studentid_202 == 40111215 & key == "uuid:209416ff-7516-4d59-b326-24039833a968"
replace reenter_schoolid = 405115 if studentid_202 == 40111215 & key == "uuid:209416ff-7516-4d59-b326-24039833a968"


replace correct_group = 2 if studentid_202 == 50310710 & key == "uuid:8015dd79-30a2-438c-950b-49d77f7e0c1c"
replace group_107 = 2 if studentid_202 == 50310710 & key == "uuid:8015dd79-30a2-438c-950b-49d77f7e0c1c"
replace schoolid = 405139 if studentid_202 == 50310710 & key == "uuid:8015dd79-30a2-438c-950b-49d77f7e0c1c"
replace reenter_schoolid = 405139 if studentid_202 == 50310710 & key == "uuid:8015dd79-30a2-438c-950b-49d77f7e0c1c"


replace correct_group = 1 if studentid_202 == 4030507 & key == "uuid:39678733-a0c8-4448-b881-7f0795128e3f"
replace group_107 = 1 if studentid_202 == 4030507 & key == "uuid:39678733-a0c8-4448-b881-7f0795128e3f"
replace schoolid = 403057 if studentid_202 == 4030507 & key == "uuid:39678733-a0c8-4448-b881-7f0795128e3f"
replace reenter_schoolid = 403057 if studentid_202 == 4030507 & key == "uuid:39678733-a0c8-4448-b881-7f0795128e3f"


replace correct_group = 2 if studentid_202 == 3010385 & key == "uuid:9b495af3-1e52-469b-aea6-c993d88672ea"
replace group_107 = 2 if studentid_202 == 3010385 & key == "uuid:9b495af3-1e52-469b-aea6-c993d88672ea"
replace schoolid = 403111 if studentid_202 == 3010385 & key == "uuid:9b495af3-1e52-469b-aea6-c993d88672ea"
replace reenter_schoolid = 403111 if studentid_202 == 3010385 & key == "uuid:9b495af3-1e52-469b-aea6-c993d88672ea"


replace correct_group = 2 if studentid_202 == 40303110 & key == "uuid:1d1e5b86-2d10-45ec-8da9-c01a367a00e5"
replace group_107 = 2 if studentid_202 == 40303110 & key == "uuid:1d1e5b86-2d10-45ec-8da9-c01a367a00e5"
replace schoolid = 403115 if studentid_202 == 40303110 & key == "uuid:1d1e5b86-2d10-45ec-8da9-c01a367a00e5"
replace reenter_schoolid = 403115 if studentid_202 == 40303110 & key == "uuid:1d1e5b86-2d10-45ec-8da9-c01a367a00e5"

replace correct_group = 2 if studentid_202 == 4031325 & key == "uuid:b360a2fb-bf6f-46b9-acac-514f79f703b5"
replace group_107 = 2 if studentid_202 == 4031325 & key == "uuid:b360a2fb-bf6f-46b9-acac-514f79f703b5"
replace schoolid = 403115 if studentid_202 == 4031325 & key == "uuid:b360a2fb-bf6f-46b9-acac-514f79f703b5"
replace reenter_schoolid = 403115 if studentid_202 == 4031325 & key == "uuid:b360a2fb-bf6f-46b9-acac-514f79f703b5"

replace correct_group = 2 if studentid_202 == 40305011 & key == "uuid:5b84f10e-4d6e-4af7-9dd8-787286393009"
replace group_107 = 2 if studentid_202 == 40305011 & key ==  "uuid:5b84f10e-4d6e-4af7-9dd8-787286393009"
replace schoolid = 403115 if studentid_202 == 40305011 & key ==  "uuid:5b84f10e-4d6e-4af7-9dd8-787286393009"
replace reenter_schoolid = 403115 if studentid_202 == 40305011 & key ==  "uuid:5b84f10e-4d6e-4af7-9dd8-787286393009"

replace correct_group = 1 if studentid_202 == 4011262 & key == "uuid:688f7832-566d-4b8e-ae44-750a5f20a2c4"
replace group_107 = 1 if studentid_202 == 4011262 & key == "uuid:688f7832-566d-4b8e-ae44-750a5f20a2c4"
replace schoolid = 403104 if studentid_202 == 4011262 & key == "uuid:688f7832-566d-4b8e-ae44-750a5f20a2c4"
replace reenter_schoolid = 403104 if studentid_202 == 4011262 & key == "uuid:688f7832-566d-4b8e-ae44-750a5f20a2c4"

replace correct_group = 1 if studentid_202 == 3040101 & key == "uuid:e3fe20b8-3b43-421d-afeb-d419928660be"
replace group_107 = 1 if studentid_202 == 3040101 & key == "uuid:e3fe20b8-3b43-421d-afeb-d419928660be"
replace schoolid = 403104 if studentid_202 == 3040101 & key == "uuid:e3fe20b8-3b43-421d-afeb-d419928660be"
replace reenter_schoolid = 403104 if studentid_202 == 3040101 & key == "uuid:e3fe20b8-3b43-421d-afeb-d419928660be"

replace correct_group = 1 if studentid_202 == 50710412 & key == "uuid:ec53273d-b258-4770-9b1b-0214f29f71f6"
replace group_107 = 1 if studentid_202 == 50710412 & key == "uuid:ec53273d-b258-4770-9b1b-0214f29f71f6"
replace schoolid = 401117 if studentid_202 == 50710412 & key == "uuid:ec53273d-b258-4770-9b1b-0214f29f71f6"
replace reenter_schoolid = 401117 if studentid_202 == 50710412 & key == "uuid:ec53273d-b258-4770-9b1b-0214f29f71f6"


replace correct_group = 2 if studentid_202 == 3050121 & key == "uuid:b4197e19-84fb-4e90-85ab-6b7a0a1c6677"
replace group_107 = 2 if studentid_202 == 3050121 & key == "uuid:b4197e19-84fb-4e90-85ab-6b7a0a1c6677"
replace schoolid = 401030 if studentid_202 == 3050121 & key == "uuid:b4197e19-84fb-4e90-85ab-6b7a0a1c6677"
replace reenter_schoolid = 401030 if studentid_202 == 3050121 & key == "uuid:b4197e19-84fb-4e90-85ab-6b7a0a1c6677"

replace correct_group = 2 if studentid_202 == 40101610 & key == "uuid:2211bb71-6d37-42f5-b331-1ab24ba0d423"
replace group_107 = 2 if studentid_202 == 40101610 & key == "uuid:2211bb71-6d37-42f5-b331-1ab24ba0d423"
replace schoolid = 401133 if studentid_202 == 40101610 & key == "uuid:2211bb71-6d37-42f5-b331-1ab24ba0d423"
replace reenter_schoolid = 401133 if studentid_202 == 40101610 & key == "uuid:2211bb71-6d37-42f5-b331-1ab24ba0d423"


replace correct_group = 1 if studentid_202 == 40205213 & key == "uuid:ff7919c2-789e-409a-a1d4-38b0b0108c8f"
replace group_107 = 1 if studentid_202 == 40205213 & key == "uuid:ff7919c2-789e-409a-a1d4-38b0b0108c8f"
replace schoolid = 401014 if studentid_202 == 40205213 & key == "uuid:ff7919c2-789e-409a-a1d4-38b0b0108c8f"
replace reenter_schoolid = 401014 if studentid_202 ==40205213& key == "uuid:ff7919c2-789e-409a-a1d4-38b0b0108c8f"

replace correct_group = 2 if studentid_202 == 3010354 & key == "uuid:22a257d5-3a3e-452d-939a-2bf124a6fc85"
replace group_107 = 2 if studentid_202 == 3010354 & key == "uuid:22a257d5-3a3e-452d-939a-2bf124a6fc85"
replace schoolid = 301033 if studentid_202 == 3010354 & key == "uuid:22a257d5-3a3e-452d-939a-2bf124a6fc85"
replace reenter_schoolid = 301033 if studentid_202 == 3010354 & key == "uuid:22a257d5-3a3e-452d-939a-2bf124a6fc85"


replace correct_group = 1 if studentid_202 == 3010114 & key == "uuid:71c74bf9-fa35-46df-bcf4-d3eab8c7847d"
replace group_107 = 1 if studentid_202 == 3010114 & key == "uuid:71c74bf9-fa35-46df-bcf4-d3eab8c7847d"
replace schoolid = 301128 if studentid_202 == 3010114 & key == "uuid:71c74bf9-fa35-46df-bcf4-d3eab8c7847d"
replace reenter_schoolid = 301128 if studentid_202 == 3010114 & key == "uuid:71c74bf9-fa35-46df-bcf4-d3eab8c7847d"

replace correct_group = 2 if studentid_202 == 40310814 & key == "uuid:be2c8e4d-a58e-4b02-8dce-d1a42c0dd549"
replace group_107 = 2 if studentid_202 == 40310814 & key == "uuid:be2c8e4d-a58e-4b02-8dce-d1a42c0dd549"
replace schoolid = 301038 if studentid_202 == 40310814 & key == "uuid:be2c8e4d-a58e-4b02-8dce-d1a42c0dd549"
replace reenter_schoolid = 301038 if studentid_202 == 40310814 & key == "uuid:be2c8e4d-a58e-4b02-8dce-d1a42c0dd549"


replace correct_group = 2 if studentid_202 == 3011104 & key == "uuid:c3d77932-82f4-40dc-8bc0-684cda900e53"
replace group_107 = 2 if studentid_202 == 3011104 & key == "uuid:c3d77932-82f4-40dc-8bc0-684cda900e53"
replace schoolid = 301011 if studentid_202 == 3011104 & key == "uuid:c3d77932-82f4-40dc-8bc0-684cda900e53"
replace reenter_schoolid = 301011 if studentid_202 == 3011104 & key == "uuid:c3d77932-82f4-40dc-8bc0-684cda900e53"

replace correct_group = 2 if studentid_202 == 3011233 & key == "uuid:53597ab5-6db1-49d2-a735-746bf93e4dce"
replace group_107 = 2 if studentid_202 == 3011233 & key == "uuid:53597ab5-6db1-49d2-a735-746bf93e4dce"
replace schoolid = 301011 if studentid_202 == 3011233 & key == "uuid:53597ab5-6db1-49d2-a735-746bf93e4dce"
replace reenter_schoolid = 301011 if studentid_202 == 3011233 & key == "uuid:53597ab5-6db1-49d2-a735-746bf93e4dce"

replace correct_group = 1 if studentid_202 == 3011284 & key == "uuid:58ab2068-854c-4789-bcd8-2cd6bc09e7a7"
replace group_107 = 1 if studentid_202 == 3011284 & key == "uuid:58ab2068-854c-4789-bcd8-2cd6bc09e7a7"
replace schoolid = 301013 if studentid_202 == 3011284 & key == "uuid:58ab2068-854c-4789-bcd8-2cd6bc09e7a7"
replace reenter_schoolid = 301013 if studentid_202 == 3011284 & key == "uuid:58ab2068-854c-4789-bcd8-2cd6bc09e7a7"

replace correct_group = 1 if studentid_202 == 5030551 & key == "uuid:babca2bc-4686-431f-bf41-8d5ee487f960"
replace group_107 = 1 if studentid_202 == 5030551 & key == "uuid:babca2bc-4686-431f-bf41-8d5ee487f960"
replace schoolid = 301013 if studentid_202 == 5030551 & key == "uuid:babca2bc-4686-431f-bf41-8d5ee487f960"
replace reenter_schoolid = 301013 if studentid_202 == 5030551 & key == "uuid:babca2bc-4686-431f-bf41-8d5ee487f960"


replace correct_group = 2 if studentid_202 == 30103715 & key == "uuid:80fcd031-8060-4ab8-9881-42cc1da5357b"
replace group_107 = 2 if studentid_202 == 30103715 & key == "uuid:80fcd031-8060-4ab8-9881-42cc1da5357b"
replace schoolid = 301015 if studentid_202 == 30103715 & key == "uuid:80fcd031-8060-4ab8-9881-42cc1da5357b"
replace reenter_schoolid = 301015 if studentid_202 == 30103715 & key == "uuid:80fcd031-8060-4ab8-9881-42cc1da5357b"

replace correct_group = 1 if studentid_202 == 3011359 & key == "uuid:ca442146-8820-4715-a6d0-782e89618065"
replace group_107 = 1 if studentid_202 == 3011359 & key == "uuid:ca442146-8820-4715-a6d0-782e89618065"
replace schoolid = 301115 if studentid_202 == 3011359 & key == "uuid:ca442146-8820-4715-a6d0-782e89618065"
replace reenter_schoolid = 301115 if studentid_202 == 3011359 & key == "uuid:ca442146-8820-4715-a6d0-782e89618065"


replace correct_group = 2 if studentid_202 == 3011122 & key == "uuid:586e3c13-ef97-4ff6-8d51-c6927fbe6bc3"
replace group_107 = 2 if studentid_202 == 3011122 & key == "uuid:586e3c13-ef97-4ff6-8d51-c6927fbe6bc3"
replace schoolid = 301123 if studentid_202 == 3011122 & key == "uuid:586e3c13-ef97-4ff6-8d51-c6927fbe6bc3"
replace reenter_schoolid = 301123 if studentid_202 == 3011122 & key == "uuid:586e3c13-ef97-4ff6-8d51-c6927fbe6bc3"

replace correct_group = 1 if studentid_202 == 3051244 & key == "uuid:90f7dfcc-caae-4b79-8f2d-1391fa00a613"
replace group_107 = 1 if studentid_202 == 3051244 & key == "uuid:90f7dfcc-caae-4b79-8f2d-1391fa00a613"
replace schoolid = 305033 if studentid_202 == 3051244 & key == "uuid:90f7dfcc-caae-4b79-8f2d-1391fa00a613"
replace reenter_schoolid = 305033 if studentid_202 == 3051244 & key == "uuid:90f7dfcc-caae-4b79-8f2d-1391fa00a613"


replace correct_group = 1 if studentid_202 == 50402014 & key == "uuid:87af3862-5a1e-4a44-884d-95f6aded3846"
replace group_107 = 1 if studentid_202 == 50402014 & key == "uuid:87af3862-5a1e-4a44-884d-95f6aded3846"
replace schoolid = 305034 if studentid_202 == 50402014 & key == "uuid:87af3862-5a1e-4a44-884d-95f6aded3846"
replace reenter_schoolid = 305034 if studentid_202 == 50402014 & key == "uuid:87af3862-5a1e-4a44-884d-95f6aded3846"

replace correct_group = 1 if studentid_202 == 350300112 & key == "uuid:486e3709-2990-43ab-97ed-9500320a2e26"
replace group_107 = 1 if studentid_202 == 350300112 & key == "uuid:486e3709-2990-43ab-97ed-9500320a2e26"
replace schoolid = 305131 if studentid_202 == 350300112 & key == "uuid:486e3709-2990-43ab-97ed-9500320a2e26"
replace reenter_schoolid = 305131 if studentid_202 == 350300112 & key == "uuid:486e3709-2990-43ab-97ed-9500320a2e26"


replace correct_group = 2 if studentid_202 == 5040114 & key == "uuid:34e57cee-e1c3-477d-a12b-ab94548b153d"
replace group_107 = 2 if studentid_202 == 5040114 & key == "uuid:34e57cee-e1c3-477d-a12b-ab94548b153d"
replace schoolid = 305037 if studentid_202 == 5040114 & key == "uuid:34e57cee-e1c3-477d-a12b-ab94548b153d"
replace reenter_schoolid = 305037 if studentid_202 == 5040114 & key == "uuid:34e57cee-e1c3-477d-a12b-ab94548b153d"

replace correct_group = 2 if studentid_202 == 3050348 & key == "uuid:4efc0be3-c7b7-499e-b624-0981315858b3"
replace group_107 = 2 if studentid_202 == 3050348 & key == "uuid:4efc0be3-c7b7-499e-b624-0981315858b3"
replace schoolid = 305135 if studentid_202 == 3050348 & key == "uuid:4efc0be3-c7b7-499e-b624-0981315858b3"
replace reenter_schoolid = 305135 if studentid_202 == 3050348 & key == "uuid:4efc0be3-c7b7-499e-b624-0981315858b3"


replace correct_group = 1 if studentid_202 == 30403314 & key == "uuid:033d1156-e623-4044-80ae-27ebcaba7aa7"
replace group_107 = 1 if studentid_202 == 30403314 & key == "uuid:033d1156-e623-4044-80ae-27ebcaba7aa7"
replace schoolid = 304105 if studentid_202 == 30403314 & key == "uuid:033d1156-e623-4044-80ae-27ebcaba7aa7"
replace reenter_schoolid = 304105 if studentid_202 == 30403314 & key == "uuid:033d1156-e623-4044-80ae-27ebcaba7aa7"

replace correct_group = 1 if studentid_202 == 3041027 & key == "uuid:cf55bacf-2c90-4195-89a1-bf4d8cd05e95"
replace group_107 = 1 if studentid_202 == 3041027 & key == "uuid:cf55bacf-2c90-4195-89a1-bf4d8cd05e95"
replace schoolid = 304105 if studentid_202 == 3041027 & key == "uuid:cf55bacf-2c90-4195-89a1-bf4d8cd05e95"
replace reenter_schoolid = 304105 if studentid_202 == 3041027 & key == "uuid:cf55bacf-2c90-4195-89a1-bf4d8cd05e95"


replace correct_group = 2 if studentid_202 == 3041024 & key == "uuid:e18213d9-09d5-4d88-9e28-6de103592292"
replace group_107 = 2 if studentid_202 == 3041024 & key == "uuid:e18213d9-09d5-4d88-9e28-6de103592292"
replace schoolid = 304105 if studentid_202 == 3041024 & key == "uuid:e18213d9-09d5-4d88-9e28-6de103592292"
replace reenter_schoolid = 304105 if studentid_202 == 3041024 & key == "uuid:e18213d9-09d5-4d88-9e28-6de103592292"

replace correct_group = 2 if studentid_202 == 30410211 & key == "uuid:75260937-8123-4792-822a-81c9afd02d09"
replace group_107 = 2 if studentid_202 == 30410211 & key == "uuid:75260937-8123-4792-822a-81c9afd02d09"
replace schoolid = 304105 if studentid_202 == 30410211 & key == "uuid:75260937-8123-4792-822a-81c9afd02d09"
replace reenter_schoolid = 304105 if studentid_202 == 30410211 & key == "uuid:75260937-8123-4792-822a-81c9afd02d09"

replace correct_group = 1 if studentid_202 == 5061054 & key == "uuid:30d5e7f6-5bd4-4274-b19a-89e61fc79478"
replace group_107 = 1 if studentid_202 == 5061054 & key == "uuid:30d5e7f6-5bd4-4274-b19a-89e61fc79478"
replace schoolid = 304107 if studentid_202 == 5061054 & key == "uuid:30d5e7f6-5bd4-4274-b19a-89e61fc79478"
replace reenter_schoolid = 304107 if studentid_202 == 5061054 & key == "uuid:30d5e7f6-5bd4-4274-b19a-89e61fc79478"

replace correct_group = 1 if studentid_202 == 3040109 & key == "uuid:ec116323-629f-4c8b-aa01-8b7c34c340d9"
replace group_107 = 1 if studentid_202 == 3040109 & key == "uuid:ec116323-629f-4c8b-aa01-8b7c34c340d9"
replace schoolid = 304109 if studentid_202 == 3040109 & key == "uuid:ec116323-629f-4c8b-aa01-8b7c34c340d9"
replace reenter_schoolid = 304109 if studentid_202 == 3040109 & key == "uuid:ec116323-629f-4c8b-aa01-8b7c34c340d9"

replace correct_group = 2 if studentid_202 == 40310813 & key == "uuid:41a2b51f-c5cf-4ec6-9169-15b7a1c74036"
replace group_107 = 2 if studentid_202 == 40310813 & key == "uuid:41a2b51f-c5cf-4ec6-9169-15b7a1c74036"
replace schoolid = 304054 if studentid_202 == 40310813 & key == "uuid:41a2b51f-c5cf-4ec6-9169-15b7a1c74036"
replace reenter_schoolid = 304054 if studentid_202 == 40310813 & key == "uuid:41a2b51f-c5cf-4ec6-9169-15b7a1c74036"

**Adding other answer options to the group_107
la def group_107 1 "Treatment" 2 "Control" 3 "Non-baseline" 4 "Dropout", modify
la values group_107 group_107

replace group_107 = 4 if dropout == 1

replace group_107 = 3 if key == "uuid:521abb95-cd88-4514-8155-d6f4060ce779"
replace group_107 = 3 if key == "uuid:af863c12-7c27-47e0-b0a7-e396fbbd5180"
replace group_107 = 3 if key == "uuid:20bb104a-6238-45f1-8f7b-e0e548bbf50d"
replace group_107 = 3 if key == "uuid:6e7edbc0-c129-4783-84f4-1699de1bc31f"
replace group_107 = 3 if key == "uuid:50c95c12-e449-4d47-8d44-4f82ffe527d0"
replace group_107 = 3 if key == "uuid:2ff2239f-c2bf-4472-9e37-dde489cb4818"
replace group_107 = 3 if key == "uuid:9d346c19-cef4-4e93-821a-bd3d5f2af2d6"
replace group_107 = 3 if key == "uuid:a1c85615-f2ff-421f-ba3f-f5e3fe6ee0ca"
replace group_107 = 3 if key == "uuid:46b8ee69-9ae0-4236-9ee2-9f95f7041dfe"
replace group_107 = 3 if key == "uuid:3958199a-ed86-42d4-bc1e-dae3d970931a"
replace group_107 = 3 if key == "uuid:973a746e-eba1-4770-b26a-0fea7a499653"
replace group_107 = 3 if key == "uuid:41f6fd7e-c98d-4b14-899b-3a3e9bfaecce"
replace group_107 = 3 if key == "uuid:e0bf364e-9f85-403a-ab46-7a7c48ab8c1a"
replace group_107 = 3 if key == "uuid:ba19c886-6e8b-47d4-8baa-5a8fbc6b0c12"
replace group_107 = 3 if key == "uuid:de693fb7-28d4-4d47-8e4b-b1620ea42137"
replace group_107 = 3 if key == "uuid:ca21daf5-5cc4-4601-8cdf-08ff60aaa758"
replace group_107 = 3 if key == "uuid:e0e27e8b-c154-483a-8528-355799e4c59b"
replace group_107 = 3 if key == "uuid:730deb5a-7cd6-4f21-b6c4-c96ec5cf2b14"
replace group_107 = 3 if key == "uuid:338015ea-0170-43e8-9fb5-ae7a76b4ea9b"
replace group_107 = 3 if key == "uuid:058df8e5-a490-4c72-aeec-37d7489ad255"
replace group_107 = 3 if key == "uuid:5c0bc03a-7149-479d-bfa8-0b035a22caed"
replace group_107 = 3 if key == "uuid:bac5394e-6137-449b-bf82-a915bd5c0c31"
replace group_107 = 3 if key == "uuid:e6bca5e5-cae1-4199-b7bc-7facb34bc206"
replace group_107 = 3 if key == "uuid:0656ef3f-e33a-4df1-8040-6933b5d9e6c9"
replace group_107 = 3 if key == "uuid:cd5ac4ac-aa85-47b2-bff0-f980af5c4014"
replace group_107 = 3 if key == "uuid:c7fac5ba-1922-4a86-b7fc-174f822f0e9f"
replace group_107 = 3 if key == "uuid:832cde1c-6ba0-4789-b7ee-01c5563e5a9f"
replace group_107 = 3 if key == "uuid:3780697a-e85f-464a-ac1d-6d8621128307"
replace group_107 = 3 if key == "uuid:ca1287d7-bd87-4049-8553-e7543fef3dc8"
replace group_107 = 3 if key == "uuid:2f7260c3-5a4e-4def-9447-60a97c162b56"
replace group_107 = 3 if key == "uuid:d4276b67-54ea-43cc-b189-56eb8c9da9ba"
replace group_107 = 3 if key == "uuid:5f980db6-4c68-4899-849e-72853978af0c"
replace group_107 = 3 if key == "uuid:1f8ee82b-e548-40b3-bc46-9f06b572d05f"
replace group_107 = 3 if key == "uuid:20150a45-9152-4e89-9b1c-797ce2771a5c"
replace group_107 = 3 if key == "uuid:c9037fc5-7ab9-4279-ab88-cb408ef59837"
replace group_107 = 3 if key == "uuid:1cb617c6-4a22-4e41-ae3b-b743a38dbef3"
replace group_107 = 3 if key == "uuid:4e42446c-11da-47d7-bc60-a4e7ac61ab6e"
replace group_107 = 3 if key == "uuid:6a85dc7d-aa73-4efe-9fec-e2d1b89fc447"
replace group_107 = 3 if key == "uuid:80959547-d919-408d-9ca2-f7c274ee5143"
replace group_107 = 3 if key == "uuid:add71852-4df4-4f5b-bfe8-8893ca563de7"
replace group_107 = 3 if key == "uuid:177633e7-53f6-4243-a14b-1d3a74420b8e"
replace group_107 = 3 if key == "uuid:9f105ca9-c674-4b38-b094-5555a33ec1f5"
replace group_107 = 3 if key == "uuid:417aaedf-8a2a-4b76-ad59-c7d71e68d7ec"
replace group_107 = 3 if key == "uuid:3d305aa8-71b9-48e6-bad8-d14ba109150b"
replace group_107 = 3 if key == "uuid:7a49d9ca-c761-4c34-be40-f636f8deb113"
replace group_107 = 3 if key == "uuid:ff753dd4-4b04-4566-b5c5-70e81c2e01e3"
replace group_107 = 3 if key == "uuid:9c747e40-8ec9-4b5b-b127-9581ecbb9c93"
replace group_107 = 3 if key == "uuid:dde0cfd1-9716-4ece-b0d2-faf14f19ecaa"
replace group_107 = 3 if key == "uuid:ca49294c-7ab0-4010-b0e4-a944205210bd"
replace group_107 = 3 if key == "uuid:ed4c6180-c9a1-4191-8b6e-d30a403df61d"
replace group_107 = 3 if key == "uuid:4df87917-325b-4ad5-b48e-41d9de8bc9af"
replace group_107 = 3 if key == "uuid:a12c6624-91ce-4593-911c-d2b87efa63e2"
replace group_107 = 3 if key == "uuid:98f83099-7739-4c12-8466-55575b158f7c"
replace group_107 = 3 if key == "uuid:a9a74240-6d62-414c-b7df-3fe3d19baba7"
replace group_107 = 3 if key == "uuid:475020d2-a913-4ee7-8be2-50de0fb65ba7"
replace group_107 = 3 if key == "uuid:e1dddabb-0df4-48d9-a13e-d15801d3b10b"
replace group_107 = 3 if key == "uuid:51767497-c4b0-41fd-b3f4-bc90ffa9e7d1"
replace group_107 = 3 if key == "uuid:bffd0d72-a39a-4e0d-9f22-2469670ba68b"
replace group_107 = 3 if key == "uuid:080805c7-5a07-45e1-97a4-92255c84a96c"
replace group_107 = 3 if key == "uuid:d08300e2-b197-4845-a523-fd0258d367b1"
replace group_107 = 3 if key == "uuid:47e8e6dd-cd20-478f-afdc-8163d09cc2ee"
replace group_107 = 3 if key == "uuid:f1e134ce-cdc3-4c2c-b1ba-5cdecf8c8cbc"
replace group_107 = 3 if key == "uuid:c84ec4f0-a13f-4a18-8d39-5430b3f7d8ab"
replace group_107 = 3 if key == "uuid:8285c1d8-df1b-4a37-9084-b1e81a23da08"
replace group_107 = 3 if key == "uuid:222a77b7-8fec-42a0-8ed7-92249e7db03f"
replace group_107 = 3 if key == "uuid:482f3abc-08e9-4b0a-a8b1-a0dfb795e86c"
replace group_107 = 3 if key == "uuid:57b29277-a94b-4db2-a394-9fc5e901fcf5"
replace group_107 = 3 if key == "uuid:c3797279-2419-492e-ba9e-94b6ed8e416a"
replace group_107 = 3 if key == "uuid:2c86c84c-19b1-40ae-9498-00882b45dd37"
replace group_107 = 3 if key == "uuid:bef8bbcd-ef16-47e3-ad38-09e5d945703c"
replace group_107 = 3 if key == "uuid:e9eff4ed-e3f6-49a0-9654-6893e4e970d9"
replace group_107 = 3 if key == "uuid:647fc377-0954-45d2-9fca-5000f496fac8"
replace group_107 = 3 if key == "uuid:13a24b57-b256-4b84-b18e-78d6109decd9"
replace group_107 = 3 if key == "uuid:3421cb5d-418a-4500-996f-240992997fa4"
replace group_107 = 3 if key == "uuid:43905af8-9c89-4c02-8c20-467ef764c43f"
replace group_107 = 3 if key == "uuid:757d1be0-cd3b-4359-9fb7-fc934c1a0da4"
replace group_107 = 3 if key == "uuid:81c60706-be5a-4051-bfb6-e1b38623e839"
replace group_107 = 3 if key == "uuid:a91a9a54-2246-4358-831e-6f2c931e3dde"
replace group_107 = 3 if key == "uuid:145e2131-0e37-4d60-bc31-d2e5b04b65c6"
replace group_107 = 3 if key == "uuid:b964096e-35c3-4e9a-9b0a-d8e709e87cbb"
replace group_107 = 3 if key == "uuid:30aa9b1b-7585-4fbe-a8e0-44c28c0ccc04"
replace group_107 = 3 if key == "uuid:7d09c493-d806-4ab5-9f59-b7a1e358fe06"
replace group_107 = 3 if key == "uuid:42aa3668-fb4f-4614-9a35-956289465ae1"
replace group_107 = 3 if key == "uuid:1d791d06-ce47-4d35-93d7-6f1d8891035a"
replace group_107 = 3 if key == "uuid:58c774a3-6154-4c81-96eb-3d1f0df81fac"
replace group_107 = 3 if key == "uuid:7a4b00e2-2208-40dc-b1cb-155788ff28d7"
replace group_107 = 3 if key == "uuid:062eca4a-45fb-4bd6-8489-122cf23fb13d"
replace group_107 = 3 if key == "uuid:b2041344-4ec8-4ab2-a1e8-730f9b967289"
replace group_107 = 3 if key == "uuid:b9e24be3-e353-4428-9725-bae873bc350a"
replace group_107 = 3 if key == "uuid:fa292c9f-9ebf-49d5-8c0d-789c8699b6fe"
replace group_107 = 3 if key == "uuid:174a9e0e-d771-4665-8e05-252e9c305c96"
replace group_107 = 3 if key == "uuid:9b73cbc5-e250-4fa5-8a2c-58858b4ae4e0"
replace group_107 = 3 if key == "uuid:a8b90eb4-416e-4363-8b36-8a161b25984c"
replace group_107 = 3 if key == "uuid:78128e0a-6a5f-4464-b8b0-b945287e231d"
replace group_107 = 3 if key == "uuid:0040ad63-3d8f-43a2-a4eb-c2cfc35ea1fc"
replace group_107 = 3 if key == "uuid:14aeaca0-a34b-46fd-9b70-cedaac80d515"
replace group_107 = 3 if key == "uuid:8a397361-9eee-45bc-88fb-68cdb26a200d"
replace group_107 = 3 if key == "uuid:ac985c32-b430-43a8-83fb-e57de6421db2"
replace group_107 = 3 if key == "uuid:94c7086a-bc95-465e-ab9f-28f2be174760"
replace group_107 = 3 if key == "uuid:dcd78bfe-810b-4a6d-8ffb-2296cfee7469"
replace group_107 = 3 if key == "uuid:b019da5c-27f1-40f2-9574-a7c607e3fb05"
replace group_107 = 3 if key == "uuid:a4bf2142-8022-465a-9070-7bd5f6201bed"
replace group_107 = 3 if key == "uuid:ff1e9916-6447-42c8-aba4-acbcd59427c8"
replace group_107 = 3 if key == "uuid:17b1f6af-d0bd-4c1d-b512-0f7c00390af0"
replace group_107 = 3 if key == "uuid:e44f8837-4bbf-417d-a2e6-97c55a1aa3b1"
replace group_107 = 3 if key == "uuid:ff92f5a6-a7e2-4330-8a08-ee29b372b450"
replace group_107 = 3 if key == "uuid:a01e3310-ed16-4fad-9a25-26ac54950600"
replace group_107 = 3 if key == "uuid:8a4d2afa-dd68-4b2e-993e-a96bddf2acfd"
replace group_107 = 3 if key == "uuid:712185e5-daae-4bc6-b07f-bad96d1b1aef"
replace group_107 = 3 if key == "uuid:44cc7257-6e16-4d04-afbc-d7c86978fe07"
replace group_107 = 3 if key == "uuid:18a22efc-27fa-4aed-aa90-b94a9c454e12"
replace group_107 = 3 if key == "uuid:66ca8a3a-ba1f-43b4-86d4-fb73acf6a231"
replace group_107 = 3 if key == "uuid:de5225c7-df1f-4892-a7b0-61eec51c27e3"
replace group_107 = 3 if key == "uuid:3f6bd035-3c79-4f10-a836-8c79a2291637"
replace group_107 = 3 if key == "uuid:3626ee5c-6685-4b9b-aeaa-63b6b2684b18"
replace group_107 = 3 if key == "uuid:545ea0e4-1a6c-477e-8192-4aa268584206"
replace group_107 = 3 if key == "uuid:f234d45f-b384-441d-963b-58051d6bb53f"
replace group_107 = 3 if key == "uuid:6153ca52-8796-4b5a-a348-4f9a0434d9ea"
replace group_107 = 3 if key == "uuid:3d48bc1a-effe-4777-a6c7-b7856bda655f"
replace group_107 = 3 if key == "uuid:016e8340-7c6c-4a5c-a993-82f4ba6e2993"
replace group_107 = 3 if key == "uuid:607a1819-3090-4c66-a533-fc9e2b0727b8"
replace group_107 = 3 if key == "uuid:59082afe-043e-4b3e-b387-a1322be198ce"
replace group_107 = 3 if key == "uuid:b75a0867-4289-4c12-b3be-524be84b17ee"
replace group_107 = 3 if key == "uuid:d1304dcd-9f5c-4323-90c1-a53a080b9c83"
replace group_107 = 3 if key == "uuid:eab306a4-ad12-48bd-8c39-c4199b2f41e9"
replace group_107 = 3 if key == "uuid:2f7fbb10-92f5-41e3-82db-94571c8cc315"
replace group_107 = 3 if key == "uuid:04627989-d941-4044-83c8-0dd3152574d4"
replace group_107 = 3 if key == "uuid:7db2d293-e530-42d9-86d6-65ae747dcccc"
replace group_107 = 3 if key == "uuid:712b53e4-7554-4406-ba48-5fe67e5bcc1c"
replace group_107 = 3 if key == "uuid:e8f07d92-f908-4a08-a2f2-7adbdf2c81a5"
replace group_107 = 3 if key == "uuid:b524c7ea-39dd-4484-ae52-546c4b4fda9e"
replace group_107 = 3 if key == "uuid:5cd8ad17-0d7b-426b-9385-7eddf24f77f3"
replace group_107 = 3 if key == "uuid:8a3d5ccf-5269-45b4-93b9-6e426f1c863d"
replace group_107 = 3 if key == "uuid:b0ebc0e7-1923-4de1-b142-f8f41041a961"
replace group_107 = 3 if key == "uuid:b1b46b63-3927-48b1-b361-2acda3f72d6e"
replace group_107 = 3 if key == "uuid:25b5a611-1231-4ef2-9697-867751b7e271"
replace group_107 = 3 if key == "uuid:87a625f7-8885-496b-b3a3-072ea399b1ae"
replace group_107 = 3 if key == "uuid:8facfe74-4491-40e7-be1a-bf67ba470059"
replace group_107 = 3 if key == "uuid:dfed4055-d6e5-4a8f-bbdb-7b96963a43b6"
replace group_107 = 3 if key == "uuid:7f6d733b-5d87-45da-8036-a852a2ee0dfd"
replace group_107 = 3 if key == "uuid:8ca0d308-9e97-49c5-b2b3-082f513ed76e"
replace group_107 = 3 if key == "uuid:5dea993a-bb98-4328-9458-7bd7dd8730b3"
replace group_107 = 3 if key == "uuid:8aceece7-8359-4439-8dc7-594aa1adb0d5"
replace group_107 = 3 if key == "uuid:42d3ad52-2d49-4230-9f02-c6e4e185888d"
replace group_107 = 3 if key == "uuid:93a41115-2e1f-4e2e-b9b3-6f97c4349640"
replace group_107 = 3 if key == "uuid:4c5855a4-cd93-4bf7-8d50-b0cfe79c9489"
replace group_107 = 3 if key == "uuid:4bda849d-b863-4ed8-bbc9-048f2378f829"
replace group_107 = 3 if key == "uuid:02cc9b95-d7bb-4882-8e0d-f17a252eb9e1"
replace group_107 = 3 if key == "uuid:4e3bc351-e4a8-4750-8e45-31d646b8d768"
replace group_107 = 3 if key == "uuid:9a0bbb69-e557-4f8c-a568-3eb600dfe335"
replace group_107 = 3 if key == "uuid:e646b826-b003-4d8f-bcf5-fbdc7626c84f"
replace group_107 = 3 if key == "uuid:d897d546-fe11-4ca5-aaf8-adbe4f248f16"
replace group_107 = 3 if key == "uuid:801d459b-86ae-4668-895c-0a65fbe1cf0d"
replace group_107 = 3 if key == "uuid:2cc33b85-4aee-4def-8989-50bc52c9de54"
replace group_107 = 3 if key == "uuid:d0038e19-dba4-4819-979c-5861cc467e2e"
replace group_107 = 3 if key == "uuid:40a47ad1-6ae9-489e-97c9-57caae69ee3a"
replace group_107 = 3 if key == "uuid:4f4116ee-dc13-4a57-81e6-c6e1fb54c7a3"
replace group_107 = 3 if key == "uuid:2373f19c-5e67-4196-b67d-1476ff79d65f"
replace group_107 = 3 if key == "uuid:7ea82871-6566-4db3-8017-11aec5d64b72"
replace group_107 = 3 if key == "uuid:5342ce62-aa8b-4c66-a853-63dd2de22cac"
replace group_107 = 3 if key == "uuid:9f935ab6-fdde-4588-a9a1-8dabf9a3d9c3"
replace group_107 = 3 if key == "uuid:4bbdaa3d-25dc-4240-9a5f-5cefa4be71ae"
replace group_107 = 3 if key == "uuid:8cb3fa0f-1913-4fbd-b02b-8228b5c9b029"
replace group_107 = 3 if key == "uuid:e133ccde-e787-4941-9970-5307b7996724"
replace group_107 = 3 if key == "uuid:a872524d-c265-4a05-8a67-8ba139592ce0"
replace group_107 = 3 if key == "uuid:d1c76e4f-b100-4599-abc7-86b4dc903e92"
replace group_107 = 3 if key == "uuid:1aa2cc8a-a8af-46ef-80a1-2d956625b783"
replace group_107 = 3 if key == "uuid:cbb06270-a431-4e8e-afbc-801cb6b56140"
replace group_107 = 3 if key == "uuid:a29f010f-5c78-44ca-a225-27fe70810555"
replace group_107 = 3 if key == "uuid:6a3b9fdc-3ff7-42d4-aae8-a68d7110f567"
replace group_107 = 3 if key == "uuid:eb8ab62f-7028-42e6-92a8-45f534ad1d84"
replace group_107 = 3 if key == "uuid:92c25d15-4a57-4a9c-a968-7f1a318dce9f"
replace group_107 = 3 if key == "uuid:0b5c36bb-7e19-4ed1-b907-b026625600e8"
replace group_107 = 3 if key == "uuid:6d898b4e-228b-40bd-91db-9b73025108f3"
replace group_107 = 3 if key == "uuid:d142f42c-e61a-4f23-9d4e-e08740fcc62d"
replace group_107 = 3 if key == "uuid:69c89785-4aed-4594-a795-9c1098c42994"
replace group_107 = 3 if key == "uuid:d3bc2c9d-0191-4732-8cba-3bc2305cb912"
replace group_107 = 3 if key == "uuid:ead866a4-df3c-43a3-ba06-005329b3a508"
replace group_107 = 3 if key == "uuid:f754ee14-f6c5-4993-b5f9-6cc95bfc4a0b"
replace group_107 = 3 if key == "uuid:769ac984-5c8e-4eeb-a9fb-ec9ae5e0535e"
replace group_107 = 3 if key == "uuid:db792df6-126b-4eb0-8aa2-d284f2f9fec0"
replace group_107 = 3 if key == "uuid:a443c678-d922-4017-b186-939148e868a7"
replace group_107 = 3 if key == "uuid:d03d8be1-24d9-4c0c-b9db-a692e01cc359"
replace group_107 = 3 if key == "uuid:8b21e4e2-14c6-4bb5-920f-557ebdb5c935"
replace group_107 = 3 if key == "uuid:2d8dbb1a-d9a6-4020-8983-607ab6952c33"

replace school_name = 40 if key == "uuid:8d666750-42c8-45e3-bd94-e56961b15b5d"
replace school_name = 30 if key == "uuid:5c3cef4c-7e8f-4196-a133-28cbc593023e"
replace school_name = 103 if key == "uuid:e05a10ef-ad76-42eb-ab41-a1b08f433b88"
replace school_name = 52 if key == "uuid:582b220c-d622-4fce-807a-16c6239bb278"
replace school_name = 51 if key == "uuid:1c15b04c-172d-49b1-bdc6-82593b3881eb"
replace school_name = 22 if key == "uuid:5e74f950-4b7c-44ad-b37f-4285ad4510c1"
replace school_name = 35 if key == "uuid:16887af3-2c6a-4744-a7bd-b718360b671b"
replace school_name = 23 if key == "uuid:e900e1ce-edb0-4439-a4a4-722b43314823"
replace school_name = 29 if key == "uuid:06a5f1e4-d525-41b3-9570-b0ee79c71915"
replace school_name = 96 if key == "uuid:82a151f1-48fc-4404-bf46-88519941b7a2"
replace school_name = 208 if key == "uuid:c37ca7a1-41ed-487c-98c8-cf1a5ca50f4e"
replace school_name = 40 if key == "uuid:d56ac44e-979f-4858-9da5-cdd5858e8a41"
replace school_name = 23 if key == "uuid:a22747cc-380c-41b6-a8f2-74b89cf5e939"
replace school_name = 28 if key == "uuid:c01e64ea-c361-43bc-b8bf-bb94dc8edc73"
replace school_name = 30 if key == "uuid:2f43460e-199f-41fa-8102-b27c2ac5cb7f"
replace school_name = 87 if key == "uuid:1d8c7293-2296-4841-9c6f-90fc1f81a21a"
replace school_name = 20 if key == "uuid:24653423-86d9-4a20-b8b6-dfe82f784bf7"

replace schoolid = 506102 if key == "uuid:fb30f23f-6276-48dc-b5dc-c285dd32ef78"
replace reenter_schoolid = 506102 if key == "uuid:fb30f23f-6276-48dc-b5dc-c285dd32ef78"
replace group_107 = 2 if key == "uuid:fb30f23f-6276-48dc-b5dc-c285dd32ef78"

replace schoolid = 403111 if key == "uuid:d900148d-08ef-4ef9-b524-c42a8aaed8aa"
replace reenter_schoolid = 403111 if key == "uuid:d900148d-08ef-4ef9-b524-c42a8aaed8aa"
replace group_107 = 2 if key == "uuid:d900148d-08ef-4ef9-b524-c42a8aaed8aa"
drop correct_group group_check

replace school_name = 80 if schoolid == 605118
replace group_107 = 1 if schoolid == 605118

replace schoolid = 504108 if schoolid == 52
replace group_107 = 1 if schoolid == 504108
replace school_name = 56 if schoolid == 504108

replace schoolid = 405120 if schoolid == 4512
replace group_107 = 1 if schoolid == 405120
replace school_name = 107 if schoolid == 405120

replace uniqueid = "405191347" if uniqueid == "45191347"
replace group_107 = 1 if schoolid == 45191347
replace school_name = 114 if schoolid == 45191347

//replace uniqueid = "5030142" if uniqueid == "50301421"
replace schoolid = 503014 if schoolid == 50301421
replace group_107 = 2 if schoolid == 503014
replace school_name = 21 if schoolid == 503014

replace schoolid = 401115 if schoolid == 40111513
replace group_107 = 2 if schoolid == 401115
replace school_name = 143 if schoolid == 401115

replace schoolid = 403129 if schoolid == 40312911
replace group_107 = 1 if schoolid == 403129
replace school_name = 121 if schoolid == 403129

replace school_name = 19 if schoolid == 503050
replace group_107 = 2 if schoolid == 503050

replace group_107 = 2 if schoolid == 504214
replace school_name = 66 if schoolid == 504214

replace schoolid = 506117 if schoolid == 5061171
replace school_name = 79 if schoolid == 506117
replace group_107 = 2 if schoolid == 506117


replace school_name = 185 if schoolid == 305124
replace school_name = 28 if schoolid == 5030403

replace schoolid = 402032 if schoolid == 402052
replace school_name = 85 if schoolid == 402032
replace group_107 = 2 if schoolid == 402032

replace schoolid = 405102 if schoolid == 5041021
replace school_name = 95 if schoolid == 405102
replace group_107 = 1 if schoolid == 405102

drop _merge

drop if uniqueid == "."

save "appended_full clean_updated.dta", replace









